package com.bw.purchase.controller;

import com.bw.common.core.domain.Result;
import com.bw.common.core.web.controller.BaseController;
import com.bw.pojo.PmsSku;
import com.bw.purchase.pojo.Do.PurchaseDo;
import com.bw.purchase.pojo.Dto.PurchaseDto;
import com.bw.purchase.pojo.Vo.PurchaseVo;
import com.bw.purchase.service.PurchaseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("purchase")
@CrossOrigin
public class PurchaseController extends BaseController {
    @Autowired
    private PurchaseService purchaseService;

    /**
     * 预警商品列表展示
     * @return
     */
    @GetMapping("warningSkuList")
    public List<PmsSku> warningSkuList(){
        List<PmsSku> list = purchaseService.warningSkuList();
        return list;
    }

    /**
     * 添加订单记录表
     * @param purchaseDo
     */
    @PostMapping("add")
    public void add(@RequestBody PurchaseDo purchaseDo){
        purchaseService.add(purchaseDo);
    }


    /**
     * 查询审核订单列表
     * @param purchaseDto
     * @return
     */
    @GetMapping("list")
    public Result purchaseList(PurchaseDto purchaseDto){
        startPage();
        List<PurchaseVo> list = purchaseService.selectPurchaseList(purchaseDto);
        return getDataTable(list);
    }


    /**
     * 采购单审核
     * @param id
     */
    @PutMapping("update/{id}")
    public void updatePurchaseStatus(@PathVariable Integer id){
        purchaseService.updatePurchaseStatus(id);
    }




}
